package com.nexus.plugin.amqp.handle;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.lang.Nullable;

/**
 * 消息发布成功时的回调
 *
 * @Date 2025/9/24 03:18
 * @Author luzhengning
 **/
@Slf4j
public class EnhancedConfirmCallback implements RabbitTemplate.ConfirmCallback {
    @Override
    public void confirm(@Nullable CorrelationData correlationData, boolean ack, @Nullable String cause) {
        String messageId = correlationData != null ? correlationData.getId() : "unknown";
        if (ack) {
            log.info("消息确认成功 - 消息ID: {}", messageId);
        } else {
            log.error("消息确认失败 - 消息ID: {}, 原因: {}", messageId, cause);
        }
    }
}
